package com.ruoyi.factorydata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.factorydata.domain.ModelInventoryFlow;
import com.ruoyi.factorydata.service.IModelInventoryFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 母版库存流水Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/warehouse/modelInventoryFlow")
public class ModelInventoryFlowController extends BaseController
{
    @Autowired
    private IModelInventoryFlowService modelInventoryFlowService;

    /**
     * 查询母版库存流水列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelInventoryFlow modelInventoryFlow)
    {
        startPage();
        List<ModelInventoryFlow> list = modelInventoryFlowService.selectModelInventoryFlowList(modelInventoryFlow);
        return getDataTable(list);
    }

    /**
     * 导出母版库存流水列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:export')")
    @Log(title = "母版库存流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelInventoryFlow modelInventoryFlow)
    {
        List<ModelInventoryFlow> list = modelInventoryFlowService.selectModelInventoryFlowList(modelInventoryFlow);
        ExcelUtil<ModelInventoryFlow> util = new ExcelUtil<ModelInventoryFlow>(ModelInventoryFlow.class);
        util.exportExcel(response, list, "母版库存流水数据");
    }

    /**
     * 获取母版库存流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelInventoryFlowService.selectModelInventoryFlowById(id));
    }

    /**
     * 新增母版库存流水
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:add')")
    @Log(title = "母版库存流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelInventoryFlow modelInventoryFlow)
    {
        return toAjax(modelInventoryFlowService.insertModelInventoryFlow(modelInventoryFlow));
    }

    /**
     * 修改母版库存流水
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:edit')")
    @Log(title = "母版库存流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelInventoryFlow modelInventoryFlow)
    {
        return toAjax(modelInventoryFlowService.updateModelInventoryFlow(modelInventoryFlow));
    }

    /**
     * 删除母版库存流水
     */
    @PreAuthorize("@ss.hasPermi('warehouse:modelInventoryFlow:remove')")
    @Log(title = "母版库存流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelInventoryFlowService.deleteModelInventoryFlowByIds(ids));
    }
}
